package com.algorithm.thePrimaryAlgorithm;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

@Slf4j
public class StringSulotionLC18 {
    public int strStr(String haystack, String needle) {
        if (needle.length() > haystack.length() ){
            return -1;
        }
        //双指针
        int left = 0;
        int right = needle.length();

        while (right<=haystack.length()){
            if (needle.equals(haystack.substring(left,right))){
                return left;
            }
            left++;
            right++;
        }
        return -1;
    }

    @Test
    public void test(){
        String haystack = "00", needle = "";
        int i = strStr(haystack, needle);
        log.info("voer {}",i);
    }
}
